<?php

namespace App\Http\Controllers\Admin;

use App;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Model\ArticleType;


class TypeController extends Controller
{
    public function index(Request $request)
    {
        return view('admin.type.index');
    }
    //添加
    public function create()
    {
        return view('admin.type.add');
    }

    //添加业务
    public function store(Request $request)
    {
        $param = $request->input();
        if (empty($param['id'])) {
            $article_type = new ArticleType();
            $article_type = $article_type->create($param);
        } else {
            $article_type = ArticleType::find($param['id']);
            //修改
            $type = set_attributes($article_type, $param);
            $type->save();
        }
    }

    //删除
    public function delete(Request $request)
    {
        $ids = $request->input('ids');
        if (ArticleType::destroy($ids)) {
            return respone_return('200', '删除成功');
        } else {
            return respone_return('0', '删除失败');
        }
    }
}
